import pymysql
from ..database import connect_to_database, close_database_connection

async def oldPwd_check(ID):
    db, ssh_tunnel = connect_to_database()
    cursor = db.cursor(cursor=pymysql.cursors.DictCursor)
    sql = "SELECT user_pass FROM user WHERE id = %s"
    try:
        cursor.execute(sql, (ID,))
        data = cursor.fetchall()
        db.commit()
    except Exception as e:
        print(e)
        data = None
        db.rollback()
    cursor.close()
    close_database_connection(db, ssh_tunnel)
    return data
